﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Quartz;
using Quartz.Impl;

namespace ERPMVC.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Bem-vindo ao ERP financeiro!";
            // construct a scheduler factory
            ISchedulerFactory schedFact = new StdSchedulerFactory();

            // get a scheduler
            IScheduler sched = schedFact.GetScheduler();
            sched.Start();
            JobDetail job = new JobDetail("pagtoSalarios", typeof(PagtoSalarioJob));

            if (sched.GetTrigger("pagtoTrigger", "contas") == null)
            {
                Trigger trigger = TriggerUtils.MakeMonthlyTrigger(5, 7, 0);
                // start on the next even hour
                trigger.StartTimeUtc = DateTime.Now;
                trigger.Name = "pagtoTrigger";
                trigger.Group = "contas";
                sched.ScheduleJob(job, trigger);
            }

            return View();
        }

        public ActionResult About()
        {
            return View();
        }
    }
}
